﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;

namespace CloudStorageLight.Core.Web
{
    public class HttpContextTraceListener : TraceListener
    {
        public override void Write(string message)
        {
            if (HttpContext.Current != null)
            {
                var list = (StringBuilder)HttpContext.Current.Items["BlobServiceLog"];
                if (list == null)
                {
                    list = new StringBuilder();
                    HttpContext.Current.Items["BlobServiceLog"] = list;
                }
                list.Append(message);
            }
        }

        public override void WriteLine(string message)
        {
            Write(message + "\n");
        }
    }
}
